package com.global.comparator;

import java.util.Comparator;

import com.global.model.GridColumn;

/**
 * GridColumn的比较规则
 * 
 * @author zly601436
 * 
 */
public class GridColumnComparator implements Comparator<GridColumn> {

	public int compare(GridColumn g1, GridColumn g2) {
		if (g1 == null && g2 == null) {
			return 0;
		} else if (g1 == null && g2 != null) {
			return -1;
		} else if (g1 != null && g2 == null) {
			return 1;
		} else {
			if (g1.getId() == g2.getId()) {
				return 0;
			} else {
				if (g1.getDisplayIndex() >= g2.getDisplayIndex()) {
					return -1;
				} else
					return 1;
			}
		}
	}
}
